package com.seal.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.seal.comm.utils.Page;
import com.seal.dao.IMessageDao;
import com.seal.dto.MessageDto;
import com.seal.model.Message;
import com.seal.service.IMessageService;

@Service("messageServiceImpl")
@Transactional(readOnly = true)
public class MessageServiceImpl implements IMessageService {

	@Resource(name = "messageDaoImpl")
	private IMessageDao messageDao;

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false, rollbackForClassName = "Exception")
	public void addMessage(Message ca) throws Exception {
		 messageDao.addMessage(ca);
	}

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false, rollbackForClassName = "Exception")
	public void deleteMessage(Message ca) throws Exception {
		 messageDao.deleteMessage(ca);
	}

	public List<Message> getAllMessage(MessageDto messageDto, Page page)
			throws Exception {
		return messageDao.getAllMessage(messageDto, page);
	}

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false, rollbackForClassName = "Exception")
	public void updateMessage(Message ca) throws Exception {
		messageDao.updateMessage(ca);
	}

	public Message getMessageById(Long id) throws Exception {
		return messageDao.getMessageById(id);
	}
	
}
